const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command

exports.main = async (event, context) => {
  try {
    console.log(event)
    return await db.collection('user').where({
      openid: event.openid
    })
      .update({
        data: {
            base: _.set(event.base)
        }
      })
  } catch (e) {
    console.error(e)
  }
}
